package o;

import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class cdw {
    private static volatile cdw ˎ;
    private final Object ˋ = new Object();
    private final SparseArray<d> ˏ = new SparseArray();

    static class d {
        private final Class<? extends cdt> ˋ;
        private volatile cdt ˏ;

        d(Class<? extends cdt> cls) {
            this.ˋ = cls;
        }

        cdt ˋ() {
            if (this.ˏ == null) {
                synchronized (this) {
                    if (this.ˏ == null) {
                        try {
                            this.ˏ = (cdt) this.ˋ.newInstance();
                        } catch (Exception e) {
                            Logger.e("DownloadProcessorManager", "Fail to new instance for: " + this.ˋ);
                        }
                    }
                }
            }
            return this.ˏ;
        }
    }

    public static cdw ˋ() {
        if (ˎ == null) {
            synchronized (cdw.class) {
                if (ˎ == null) {
                    ˎ = new cdw();
                }
            }
        }
        return ˎ;
    }

    private cdw() {
    }

    public void ˋ(int i, @NonNull Class<? extends cdt> cls) {
        synchronized (this.ˋ) {
            this.ˏ.put(i, new d(cls));
        }
    }

    @Nullable
    public cdt ॱ(int i) {
        cdt ˋ;
        synchronized (this.ˋ) {
            d dVar = (d) this.ˏ.get(i);
            if (dVar != null) {
                ˋ = dVar.ˋ();
            } else {
                ˋ = null;
            }
        }
        return ˋ;
    }
}
